package sorting;

import java.util.Arrays;

import util.Heap;
import util.ArrayUtil;

public class HeapSort {
	public void heapSort(Float[] numbers)
	{
		int heapSize = numbers.length;
		Heap.buildMaxHeap(numbers, heapSize);

		while(heapSize != 1)
		{
			ArrayUtil.each(numbers, 0, heapSize - 1);
			
			Heap.maxHeapify(numbers, 0, -- heapSize);
		}
	}
	
	public static void main(String[] args) {
		HeapSort heap = new HeapSort();
		
		Float[] abc = new Float[]{7f, 6f, 5f, 4f, 3f, 2f, 1f};
		heap.heapSort(abc);
		
		System.out.println(Arrays.toString(abc));
	}
}
